home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
dattim
/
datetime.frm
< prev
next >
Wrap
Text File
|
1995-05-08
|
4KB
|
129 lines
VERSION 2.00
Begin Form Form1
BackColor = &H00C0C0C0&
Caption = "Date/Time Example"
ClientHeight = 5580
ClientLeft = 870
ClientTop = 1530
ClientWidth = 4680
Height = 5985
Left = 810
LinkMode = 1 'Source
LinkTopic = "Form1"
ScaleHeight = 5580
ScaleWidth = 4680
Top = 1185
Width = 4800
Begin DirListBox Dir1
Height = 4152
Left = 432
TabIndex = 2
Top = 1296
Width = 1956
End
Begin FileListBox File1
Height = 4320
Left = 2556
TabIndex = 3
Top = 1008
Width = 1770
End
Begin DriveListBox Drive1
Height = 288
Left = 432
TabIndex = 1
Top = 1008
Width = 1956
End
Begin PictureBox pic1
Height = 552
Left = 432
ScaleHeight = 525
ScaleWidth = 3870
TabIndex = 0
Top = 108
Width = 3900
End
Begin Label Label1
Alignment = 2 'Center
BackColor = &H00C0C0C0&
Caption = "Double Click a file to display it's date/time"
ForeColor = &H00000080&
Height = 228
Left = 252
TabIndex = 4
Top = 720
Width = 4332
End
End
DefInt A-Z
Sub Dir1_Change ()
pic1.Cls
file1.path = dir1.path
End Sub
Sub Drive1_Change ()
pic1.Cls
x = drive1.listindex
drive$ = RTrim$(drive1.list(x))
dir1.path = drive$
file1.path = drive$
End Sub
Sub File1_DblClick ()
'================================================================
' Double clicking on the file list box will display the files
' full path, name, date, time and size in the pic1 control
'================================================================
x = file1.listindex
file$ = file1.path
'=== setup the full path to the desired file
If Right$(file$, 1) = "\" Then
file$ = file$ + RTrim$(file1.list(x))
Else
file$ = file$ + "\" + RTrim$(file1.list(x))
End If
'=== setup an OFSTRUCT data structure
Dim a As OFSTRUCT
'=== call the OpenFile api call to get needed data
x = OpenFile(file$, a, OF_EXIST)
'=== construct the date/time stamp
fmonth = ((a.r1 And &H7FFF) \ 32) And &HF
fday = a.r1 And &H1F
fyear = (a.r1 And &H7FFF) \ 512 + 80
fhour = (a.r2 And &H7FFF) \ 2048
ampm$ = "am"
If a.r2 < 0 Then
fhour = (fhour + 16) - 12
ampm$ = "pm"
End If
If fhour >= 12 Then
If fhour > 12 Then fhour = fhour - 12
ampm$ = "pm"
ElseIf fhour = 0 Then
fhour = 12
ampm$ = "am"
End If
fminute = ((a.r2 And &H7FFF) \ 32) And &H3F
fsecond = (a.r2 And &H1F) * 2
'=== get the file size
Open file$ For Binary As #1
y& = LOF(1)
Close
'=== display the data in pic1
pic1.Cls
pic1.Print file$
pic1.Print Format$(fmonth, "0#"); "/"; Format$(fday, "0#"); "/"; Format$(fyear, "0#"); " "; Format$(fhour, "00"); ":"; Format$(fminute, "00"); ":"; Format$(fsecond, "00"); " "; ampm$;
pic1.Print " "; Format$(y&, "##,###,###"); " bytes"
End Sub